<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <script>
        function oAuth(url,client_id,client_secret,scope) {
            let redirect_uri = encodeURIComponent(window.location.href)
            let loginLink = `${url}?client_id=${client_id}&redirect_uri=${redirect_uri}&scope=${scope}`
            console.log("登录地址：", window.location.href)
            window.location.href = loginLink
        }
    </script>
</head>

<body>
    <!-- <script type="text/javascript">
        (() => {
            let url = "https://github.com/login/oauth/authorize"
            let client_id = `452ff3b98383151a089c` //xx-space-local-dev
            let client_secret = `2565591bd9a3d9283f07fad9f9635c734f467045`
            let redirect_uri = encodeURIComponent(window.location.href)
            let loginLink = `${url}?client_id=${client_id}&redirect_uri=${redirect_uri}&scope=public_repo`
            console.log("登录地址：", window.location.href)
            let nowHref = window.location.href
            let hasCode = /code/
            let hasAccesssCode = /access_token/
            if (hasCode.test(nowHref)) {
                let code = nowHref.split("=")[1]
                console.log("获得code", code);
                Toaster.postMessage(code);
                // let url_token = "https://github.com/login/oauth/access_token"
                // let getTokenUrl =
                //     `${url_token}?client_id=${client_id}&client_secret=${client_secret}&code=${code}&redirect_uri=${redirect_uri}&scope=public_repo`
                // let getTokenUrl2 =
                //     `${url_token}?client_id=${client_id}&client_secret=${client_secret}&code=${code}&scope=public_repo`
                // console.log("请求的url：", getTokenUrl)
                // window.location.href = getTokenUrl
            } else if (hasAccesssCode.test(nowHref)) {
                console.log("获得access token")
            } else {
                window.location.href = loginLink
            }
        })()
    </script> -->
</body>

</html>